//https://leetcode.cn/problems/dui-cheng-de-er-cha-shu-lcof/
class Solution {
public:
    bool isSymmetric(TreeNode* root) {
        if (root == nullptr)
        {
            return true;
        }

        return _isSymmetric(root, root);
    }

    bool _isSymmetric(TreeNode* lt, TreeNode* rt)
    {
        if (!lt && !rt)
        {
            return true;
        }
        if (!lt || !rt)
        {
            return false;
        }

        return lt->val == rt->val && _isSymmetric(lt->left, rt->right)
            && _isSymmetric(lt->right, rt->left);
    }
};